|
In computer science, the Tak function is a recursive function, named after Ikuo Takeuchi (竹内郁雄). It is defined as follows:
This function is often used as a benchmark for languages with optimization for recursion.〔 〕〔 ("Recursive Methods" ) by Elliotte Rusty Harold 〕 ==tak() vs. tarai()== The original definition by Takeuchi was as follows: tarai is short for ''tarai mawashi'', "to pass around" in Japanese. John McCarthy named this function tak() after Takeuchi.〔 〕 However, in certain later references, the y somehow got turned into the z. This is a small, but significant difference because the original version benefits significantly by lazy evaluation. Though written in exactly the same manner as others, the Haskell code below runs much faster. You can easily accelerate this function via memoization yet lazy evaluation still wins. The best known way to optimize tarai is to use mutually recursive helper function as follows. Here is an efficient implementation of tarai() in C: Note the additional check for (x <= y) before z (the third argument) is evaluated, avoiding unnecessary recursive evaluation. 抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「Tak (function)」の詳細全文を読む スポンサード リンク
|